//
//  StringUtils.m
//  oos4ios
//
//  Created by Pablo Gonzalez on 3/2/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <Oos4ios/Utils/StringUtils.h>


@implementation StringUtils

+ (NSString *) removePrefix: (NSString *) prefix fromString:(NSString *) string
{
    return [[string stringByReplacingOccurrencesOfString:prefix withString:@""] lowercaseString];
}

+ (NSString *) urlEncode: (NSString *) string {
    return [(NSString *)
    CFURLCreateStringByAddingPercentEscapes(NULL,
                                            (CFStringRef) string,
                                            NULL,
                                            (CFStringRef) @"!*'();:@&=+$,/?%#[]",
                                            kCFStringEncodingUTF8) autorelease];
}

// Decode a percent escape encoded string.
+ (NSString*) urlDecode: (NSString *) string {
    return [(NSString *)
    CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL,
                                                            (CFStringRef) string,
                                                            CFSTR(""),
                                                            kCFStringEncodingUTF8) autorelease];
}

@end
